<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class CommonUpload extends AdminController {

	function __construct() {
		parent::__construct();
		$this -> load -> model("File_model");
		$this -> load -> model("User_model");
		$this -> load ->library('ProjectService/upload_img_service');
	}



	//上传文件
	function UploadFile($now_type){
		if(count($_FILES["myfile"]['name']) <= 1){
			if($_FILES["myfile"]["size"][0] > '20971520') {
		 		exit(retJson("上传的文件太大，不能超过20M",false));
			}
			$pathlist = $this->upload_img_service->UploadFile($now_type);
			$path =  $pathlist['path'];
			$fileName =  $pathlist['name'];
		//	pri($path);
			exit(retJson('返回成功',true,$path,$fileName));
		}else{
			exit(retJson("请单文件上传!",false));
		}

	}

	//上传文件
	function UploadImg(){

		if(count($_FILES["myfile"]['name']) <= 1){
		 	if($_FILES["myfile"]["size"] > '20971520') {
		 		exit(retJson("上传的图片太大，不能超过20M",false));
			}
			$pathlist = $this->upload_img_service->UploadImg();
			$path =  $pathlist['path'];
			exit(retJson('返回成功',true,$path));
		}else{
			exit(retJson("请单文件上传!",false));
		}

	}





	

	//下载文件
	// function downloadFile(){
	// 	$path = $_POST['files']; //得到文件名
 //   		 $pathlist = $this->upload_img_service->download($path);
	// 	exit(retJson('返回地址',true,$path));
	// }

	//删除文件	
	// function deleteFile(){
	// 	if($_POST){
	// 		if(file_exists($_POST['files'])){
	// 			pri($_POST['files']);
	// 			unlink($_POST['files']);
	// 		}

	// 		if(isset($_POST['files_id'])){
	// 			$param['id'] = $_POST['files_id'];
	// 			$param['src'] ='';//清空
	// 			$this -> File_model -> update($param);
	// 		}
	// 	}
	// 	exit(retJson('删除成功',true));

	// }

}